package com.da.javatest.interview.basic.init;

/**
 * @author JokerDa.
 * @date 2025/4/16 15:23
 * Description:
 */
class Father {
    private int a;

    public Father() {
        System.out.println("(1)Father 无参构造器");
    }

    public Father(int a) {
        this.a = a;
        System.out.println("(2)Father 有参构造器");
    }

    {
        System.out.println("(3)Father 代码块");
    }

    static {
        System.out.println("(4)Son 静态代码块");
    }
}

class Son extends Father {
    private int b;

    public Son() {
        System.out.println("(5)Son 无参构造器");
    }

    public Son(int a, int b) {
        this.b = b;
        System.out.println("(6)Son 有参构造器");
    }

    {
        System.out.println("(7)Son 代码块");
    }

    static {
        System.out.println("(8)Son 静态代码块");
    }
}

public class TestInit {
    public static void main(String[] args) {
        Son son = new Son();
        Son son2 = new Son(1,2);
    }
}
